<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    


<script>
    // 创建实例

    // 直接调用父类型的构造函数
    function Person (name, age) {
        // TheTwoFather.call(this, car, money)

        this.name = name
        this.age = age

        // this.sayName = function () {
        //     console.log(`我的名字是${this.name},我的年龄是${this.age}`)
        // }
    }

    function TheTwoFather (car, money) {
        this.car = car
        this.money = money
    }

    let shenmi = new TheTwoFather('???', 1000000000000000000)

    // 原型链,父对象

    // Person的原型对象指向shenmi
    // 修改原型对象
    Person.prototype = shenmi

    Person.prototype.sayName = function () {
        console.log(`我的名字是${this.name},我的年龄是${this.age}`)
    }

    let lilei  = new Person('lilei', 18)
    let hmm  = new Person('hmm', 17)

    // 面试点----new做了什么
    // 创建一个新对象
    // 将构造函数的作用域赋值给这个新对象,this指向新对象
    // 将构造函数内的属性添加到对象中
    // 返回这个对象

    // js中所有对象的顶层对象是Object

    console.log(lilei)
    lilei.sayName()
    console.log('lilei.money', lilei.money)
    console.log(hmm)
    hmm.sayName()
    // console.log(shenmi)
    // console.log(shenmi.money)
</script>

</body>
</html>